{% extends 'base.html' %}
{% block title %}
注册
{% endblock %}
{% block noon %}
<script src="/static/js/regist.js"></script>
{% if msg %}
	<script>
		$(function () {
			alert("{{ msg }}")
		})
	</script>
{% endif %}
<div class="registration-form">
	 <div class="container">
		 <ol class="breadcrumb">
		  <li><a href="/index/">主页面</a></li>
		  <li class="active">注册</li>
		 </ol>
		 <h2>注册</h2>
		 <div class="col-md-6 reg-form">
			 <div class="reg">
				 <p>欢迎，请填写下列信息</p>
				 <form action="/register/" method="post" enctype="multipart/form-data">
					 {% csrf_token %}
					 <ul>
						 <li class="text-info">用户名: </li>
						 <li><input type="text" value="" name="useraccount"></li>
					 </ul>
					 <ul>
						 <li class="text-info">昵称: </li>
						 <li><input type="text" value="" name="username"></li>
					 </ul>				 

					 <ul>
						 <li class="text-info">密码: </li>
						 <li><input type="password" value="" name="password"></li>
					 </ul>
					 <ul>
						 <li class="text-info">确认密码:</li>
						 <li><input type="password" value="" name="trypassword"></li>
					 </ul>
					 <ul>
						 <li class="text-info">手机号:</li>
						 <li><input type="text" value="" name="phone"></li>
					 </ul>
                     <ul>
						 <li class="text-info">邮箱: </li>
						 <li><input type="text" value="" name="email"></li>
                         <li class="text-info"></li>
                         <li><input type="button" value="获取邮箱验证码" id="emailget"></li>
					 </ul>
					 <ul>
						 <li class="text-info">输入验证码:</li>
						 <li><input type="text" value="" name="yzm"></li>
					 </ul>
					 <ul>
						 <li class="text-info">头像上传</li>
						 <li><input type="file" name="userimg"></li>
					 </ul>
					 <input type="submit" name="submit" value="立即注册">
                 </form>
			 </div>
		 </div>

	 </div>
</div>
<script>
	$(function(){
		emailbotton = document.getElementById('emailget');
        emailbotton.onclick=function () {
		    email = document.getElementsByName("email")[0];
			emailadress=email.value;
			$.ajax(
                {
                    url : '/email/' + emailadress + "/",
                    type : 'GET',
                    success : function (data) {
                        if (data.msg == "ok") {
                            alert("邮件发送成功")
							window.open(data.remail,"_blank")
                        } else {
                            alert("邮件发送失败")
                        }

                    }
                }
			)
        };
	})
</script>
{% endblock %}
		